package com.itheima.employee.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.employee.mapper.ResignationMapper;
import com.itheima.employee.pojo.EmployeeResignation;
import com.itheima.employee.service.ResignationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;


/**
 * @author qiankaofei
 * @version 1.0
 * @date 2020/11/16 10:45
 */
@Service
@Transactional
public class ResignationServiceImpl implements ResignationService {

    @Autowired
    private ResignationMapper resignationMapper;

    /**
     * 离职信息保存
     */
    @Override
    public Integer save(EmployeeResignation resignation) {
        resignation.setCreateTime(new Date());
        return resignationMapper.insert(resignation);
    }

    /**
     * 离职信息读取
     */
    @Override
    public EmployeeResignation findById(String userId) {
        QueryWrapper<EmployeeResignation> wrapper=new QueryWrapper<EmployeeResignation>();
        wrapper.eq("user_id",userId);
        return resignationMapper.selectOne(wrapper);
    }

}
